<div id="content-header">
    <h1><?php echo $this->request->data['Question']['name'];?></h1>
</div>
<div id="breadcrumb">
    <a href="<?php echo $this->Html->url('/admin/')?>" title="Go to Home" class="tip-bottom"><i class="icon-home"></i> <?php echo __d('system','Home');?></a>
    <a href="#"><?php echo __d('system','Replay Question');?></a>
</div>
<div class="container-fluid">

<div class="row-fluid">
    <div class="span12">
        <?php
            echo $this->Html->script('ckeditor/ckeditor');
            echo $this->Form->create('Question', array('id' => 'paginate','class'=>'form-horizontal', 'action' => 'edit', 'url' => $this->request->here(false), 'type' => 'file',
                'inputDefaults' => array('label' => false, 'format' => array('before', 'label', 'between', 'input', 'after', 'error'))));

            echo $this->Html->script('ckeditor/ckeditor');
            echo $this->element('toolbar');
        ?>                                    
        <div class="widget-box">
            <?php                               
                $fieldsets['name'] = $this->Form->input('name', array(
                        'label' => array('text'=>__d('system','Name'),'class' => 'control-label'),
                        'between' => '<div class="controls">',
                        'div' => array('class' => 'control-group'),                        
                        'after' => '</div>',                                                           
                        'type' => 'text')); 
                $fieldsets['alias'] = $this->Form->input('alias', array(
                        'label' => array('text'=>__d('system','Alias'),'class' => 'control-label'),
                        'between' => '<div class="controls">',
                        'div' => array('class' => 'control-group'),                        
                        'after' => '</div>',                                                           
                        'type' => 'hidden'));
                $fieldsets['enabled'] = $this->Form->input('enabled', array(
                        'label' => array('text'=>__d('system','Enabled'),'class' => 'control-label'),
                        'between' => '<div class="controls">',
                        'div' => array('class' => 'control-group'),                        
                        'after' => '</div>',                                                           
                        'type' => 'checkbox')); 
                $fieldsets['address'] = $this->Form->input('address', array(
                        'label' => array('text'=>__d('system','Address'),'class' => 'control-label'),
                        'between' => '<div class="controls">',
                        'div' => array('class' => 'control-group'),
                        'after' => '</div>',                           
                        'type' => 'text'));                
                $fieldsets['email'] = $this->Form->input('email', array(
                        'label' => array('text'=>__d('system','Email'),'class' => 'control-label'),
                        'between' => '<div class="controls">',
                        'div' => array('class' => 'control-group'),
                        'after' => '</div>',                          
                        'type' => 'text'));
                $subsite = Configure::read('App.themes.listSubSite');                
                $fieldsets['sub_site'] = $this->Form->input('sub_site', array(
                        'label' => array('text'=>__d('system','Sub Site'),'class' => 'control-label'),
                        'between' => '<div class="controls">',
                        'div' => array('class' => 'control-group'),
                        'after' => '</div>',
                        'options'=>$subsite,                          
                        'type' => 'select'));
                $fieldsets['subject'] = $this->Form->input('subject', array(
                        'label' => array('text'=>__d('system','Tiêu đề'),'class' => 'control-label'),
                        'between' => '<div class="controls">',
                        'div' => array('class' => 'control-group'),
                        'after' => '</div>',                          
                        'type' => 'text'));
                $subject = ClassRegistry::init('Node.Node')->find('list',array(
                    'conditions'=>array('Node.node_type_id'=>Category_Question),
                    'fields'=>array('Node.id','Node.title'),
                    'locale'=>true
                ));                                
                $fieldsets['node_id'] = $this->Form->input('node_id', array(
                        'label' => array('text'=>__d('system','Subject'),'class' => 'control-label'),
                        'between' => '<div class="controls">',
                        'div' => array('class' => 'control-group'),
                        'after' => '</div>',
                        'options'=>$subject,                          
                        'type' => 'select'));                 
                $fieldsets['question'] = $this->Form->input('question', array(
                        'label' => array('text'=>__d('system','Question'),'class' => 'control-label'),
                        'between' => '<div class="controls">',
                        'div' => array('class' => 'control-group'),
                        'after' => '</div>',                                                                                   
                        'type' => 'textarea')); 
                $fieldsets['answer'] = $this->Form->input('answer', array(
                        'label' => array('text'=>__d('system','Answer'),'class' => 'control-label'),
                        'between' => '<div class="controls">',
                        'div' => array('class' => 'control-group'),
                        'after' => '</div>',
                        'class'=>'ckeditor',                                                           
                        'type' => 'textarea'));
                $fieldsets['attach_file'] = $this->Form->input('attach_file', array(
                        'label' => array('text'=>__d('system','Attach File'),'class' => 'control-label'),
                        'between' => '<div class="controls">',
                        'div' => array('class' => 'control-group'),
                        'after' => '</div>',                                                                             
                        'type'  => 'file'));                
                $output = "<div class=control-group>";
                $output .= "<span class = lbl-move>Move for Subsite</span>";
                if(!empty($subSiteModify)){
                    foreach($subSiteModify as $k=>$v){         
                        $chk_move = ClassRegistry::init('Node.MoveQuestion')->find('first',array(
                            'conditions'=>array('MoveQuestion.question_id'=>$id,'MoveQuestion.subsite_id'=>$k)
                        ));                                                                      
                        $output .= "<label for=QuestionEnabled class=move-label>";
                        $output .= $v;
                        $output .= "</label>";                 
                        $output .= "<input type=checkbox name=data[Question][is_move][] class=check_move value='".$k."'";                                            
                        if(!empty($chk_move)){
                            $output .= "checked";    
                        }                        
                        $output .= "/>";                        
                    }
                }
                $output .= "</div>";                                           
                $fieldsets['attach_file'] .= $output;               
            ?>            
            <?php           
                $layout = array(
                    array('name','address'),
                    array('alias'),
                    array('email','sub_site'),
                    array('subject','node_id'),
                    array('question'),
                    array('answer','attach_file'),
                    array('enabled')                               
                );                
                $layout = array(
                    array(
                        'Basic setting',
                        $layout,
                    )
                );
                echo $this->Layout->form($layout, $fieldsets);
            ?>        
        </div>       
        <?php    
            echo $this->Form->hidden('node_type_id');
            echo $this->Form->hidden('Paginate.task', array('id' => 'task', 'value' => ''));
            echo $this->Form->end();
        ?>                                   
    </div>    
</div>
<style type="text/css">
    .move-label{clear: both;margin-top: 2px !important;padding-left: 35px;}
    .lbl-move{float: left;padding-left: 73px;}
</style>
